package sig.dao.relational.impl.jpa;

import java.util.List;

import sig.dao.relational.IDaoUser;
import sig.model.entities.SigUser;

import javax.persistence.Query;
public class DaoUser  extends DaoBaseJpa<SigUser> 
implements IDaoUser {

	@Override
	public SigUser login(String login, String password) {
		
		Query query = this.getEntityManager().createQuery(
				"from SigUser where login = :login and password = :password ");
		
		query.setParameter("login", login);
		query.setParameter("password", password);
				
		@SuppressWarnings("unchecked")
		List<SigUser> result = query.getResultList();
		
		if (result.size()==0){
			return null;
		}
		return result.get(0);
	}

}
